/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "menus")
public class Menus extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Menus";
	public static final String ALIAS_MENU_ID = "menuId";
	public static final String ALIAS_PARENT_MENU_ID = "parentMenuId";
	public static final String ALIAS_MENU_NAME = "menuName";
	public static final String ALIAS_URL = "url";
	public static final String ALIAS_TYPE = "type";
	public static final String ALIAS_STATUS = "status";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * menuId       db_column: menuId 
     */ 	
	
	private java.lang.Long menuId;
    /**
     * parentMenuId       db_column: parentMenuId 
     */ 	
	
	private java.lang.Long parentMenuId;
    /**
     * menuName       db_column: menuName 
     */ 	
	@NotBlank @Length(max=50)
	private java.lang.String menuName;
    /**
     * url       db_column: url 
     */ 	
	@Length(max=500)
	private java.lang.String url;
    /**
     * type       db_column: type 
     */ 	
	
	private java.lang.Integer type;
    /**
     * status       db_column: status 
     */ 	
	
	private java.lang.Integer status;
	//columns END


	public Menus(){
	}

	public Menus(
		java.lang.Long menuId
	){
		this.menuId = menuId;
	}

	

	public void setMenuId(java.lang.Long value) {
		this.menuId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "menuId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMenuId() {
		return this.menuId;
	}
	
	@Column(name = "parentMenuId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getParentMenuId() {
		return this.parentMenuId;
	}
	
	public void setParentMenuId(java.lang.Long value) {
		this.parentMenuId = value;
	}
	
	@Column(name = "menuName", unique = false, nullable = false, insertable = true, updatable = true, length = 50)
	public java.lang.String getMenuName() {
		return this.menuName;
	}
	
	public void setMenuName(java.lang.String value) {
		this.menuName = value;
	}
	
	@Column(name = "url", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getUrl() {
		return this.url;
	}
	
	public void setUrl(java.lang.String value) {
		this.url = value;
	}
	
	@Column(name = "type", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getType() {
		return this.type;
	}
	
	public void setType(java.lang.Integer value) {
		this.type = value;
	}
	
	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(java.lang.Integer value) {
		this.status = value;
	}
	
	
	private Set menuss = new HashSet(0);
	public void setMenuss(Set<Menus> menus){
		this.menuss = menus;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "menus")
	public Set<Menus> getMenuss() {
		return menuss;
	}
	
	private Menus menus;
	public void setMenus(Menus menus){
		this.menus = menus;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "parentMenuId",nullable = false, insertable = false, updatable = false) 
	})
	public Menus getMenus() {
		return menus;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("MenuId",getMenuId())
			.append("ParentMenuId",getParentMenuId())
			.append("MenuName",getMenuName())
			.append("Url",getUrl())
			.append("Type",getType())
			.append("Status",getStatus())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getMenuId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Menus == false) return false;
		if(this == obj) return true;
		Menus other = (Menus)obj;
		return new EqualsBuilder()
			.append(getMenuId(),other.getMenuId())
			.isEquals();
	}
}

